<template>
	<el-dialog title="" :append-to-body="true" :visible.sync="dialogTableVisible" class="wrap" size="tiny">
		 <div class="bt">换老师</div>
	<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
		<el-form label-width="100px" class="form">
			<el-form-item label="新老师">
				  <el-select v-model="form.lsid" class="select-block1">
				  <el-option :label="v.zwm" :value="v.id" v-for="v in comboxlist"></el-option>
			      </el-select>
			      <el-button type="" size="mini" @click="lskb()" icon="el-icon-question"></el-button>
			</el-form-item>
			<el-form-item label="原老师">
				  <el-input v-model="form.lsmc" :readonly='true'  icon="info" class="select-block"></el-input>
			</el-form-item>
		</el-form>
		<Lskb class="lskb"  @close="lskbcancel" v-if="showlskblist" :params="form.lsid"></Lskb>
		<el-button type="primary" class="submit" @click="submit">确定</el-button>
		<el-button type="danger" class="submit" @click="cancel">退出</el-button>
	</el-dialog>
</template>

<script type="text/javascript">
	import qs from 'qs'
	import Lskb from '../../admin/yushebjManage/kebiao/lskb'
	export default {
		props: ['params'],
		components: {Lskb },
		data() {
			return {
				dialogTableVisible: true,
				showlskblist: false,
				form: {
					lsid :'',
					lsmc:'',
					id:'',
					zclsid:'',
				},
				comboxlist: []
			}
		},
		created() {
           this.getcomboxlist();
          if(this.$route.query.iid){
				this.form.id=this.$route.query.iid;
			}else{
				this.form.id=this.params.id;
			}
			if(this.$route.query.lsmc) {
				this.form.lsmc=this.$route.query.lsmc;
			}else{
				this.form.lsmc=this.params.lsmc;
			}
			if(this.$route.query.lsid) {
				this.form.lsid=this.$route.query.lsid;
			}else{
				this.form.lsid=this.params.lsid;
			}
					
			this.form.zclsid=this.params.lsid
		},
		methods: {
				submit() {
					if(!this.form.lsid) {
					this.$message.warning('请选择新老师');
					this.$store.state.loading = false;
					return;
				}
				//检测
				this.$store.state.loading = true;
				//装载数据
				var logininfo = JSON.parse(localStorage.logininfo);
				var params2 = qs.stringify({
					bjid: this.form.id+'',
					zrlsid: this.form.lsid,
					zclsid: this.form.zclsid+''
				})
				//执行
				this.axios.post(this.$store.state.api + 'bj/hls', params2)
					.then(res => {
					    if(res.data.code == 1) {
							this.$emit('close', { type: 'hls', cancel: false });
							this.$message.success(res.data.msg);
							this.$store.state.loading = false;
						} else {
						this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.danger("服务器异常");
						this.$store.state.loading = false;
					})
			},
			getcomboxlist() {
				var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
						xxid: logininfo.xxid
               })
             //执行
                 this.axios.post(this.$store.state.api + 'ls/mc',  params2 )
                 .then(res => {
					let data = res.data.data;
					let list = data;
					this.comboxlist = list;
                 }).catch(res => {
                  this.searchLoading = false;
				})
			},
			lskb(){
				this.showlskblist = true;
			},
			lskbcancel(setting) {
				// if(setting.cancel == false){
				// 	this.vfxkcid = setting.data[0].id;
				// 	this.vfxkcidmc = setting.data[0].mc;
				// 	this.vkssl = setting.data[0].number;
				// }
				this.showlskblist = false;
			},
			cancel() {
				this.$emit('close', { type: 'hls', cancel: true })
			},
		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		text-align: center;
	}
	.form {
		text-align: left;
		margin-top: 20px;
	}
	 .input {
            width: 300px;
            display: inline-block;
        }
     .close {
		    position: absolute;
		    top: 18px;
		    right: 20px;
		    color: #8492A6;
		    font-size: 16px;
        }
	.select-block {
		display: block;
		width: 85%;
	}
	.select-block1 {
		width: 76%;
	}
	.lskb {
			width: 100%;
			background: #fff;
			position: absolute;
			top: -100px;
			left: 0%;
			z-index: 50;
			padding-bottom: 100px;
		}
    .bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			background: #50BFFF;
			top:0;
			left:0;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
	.submit {
		width: 120px;
	}
</style>
